<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.dao.EquipmentDetailsDAO"%>
<%@page import="iwpl.project.entities.EquipmentDetails"%>
<%@page import="iwpl.project.dao.ApartmentsDAO"%>
<%@page import="iwpl.project.entities.Apartments"%>
<%@page import="iwpl.project.dao.EquipmentsDAO"%>
<%@page import="iwpl.project.entities.Equipments"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Update_EquipmentDetails.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body> 
    <form class="cmxform" id="commentForm" action="./servlet/Control_EquipmentDetail"  method="get">


			<%
            	
            		int sStatus = 0;
            		String sEquipdID = "";
            		String sApartID="";
            		String sEquipID="";
            		
            		String sID = request.getParameter("id");
            		
            		EquipmentDetailsDAO dao = new EquipmentDetailsDAO();
            		EquipmentDetails equipd = dao.findById(Integer.parseInt(sID));
            		
            		
            		sEquipdID = equipd.getId().toString();
            		sApartID = equipd.getApartments().getId().toString();
            		sEquipID = equipd.getEquipments().getId().toString();
            		
            		
            		
            		
            %>




			<style type="text/css">
label.error {
	float: none;
	color: red;
	padding-left: .5em;
	vertical-align: top;
}
</style>



			<tr>
				<td>
					<br />
				</td>
			</tr>
			<form id="form1" runat="server">
				<div align="center">
					<tr>
						<td><h1>
												Update EquipmentDetails
											</h1>
							<table width="454" border="1" height="296">
								<tbody>
									<tr>
										<td>
											
										</td>
										
										
									</tr>
									<tr>
										<td>
											&nbsp;EquipmentDetail ID
										</td>
										<td> 
											&nbsp;
											<input type="hidden" name="hiddenid" value="<%=sEquipdID%>" />
											<label><%=sEquipdID%></label>
										</td>
										
									</tr>
									<tr>
										<td>
											&nbsp;Number Apartment
										</td>
										<td>&nbsp;
										<select id="cboApartmentNumber" name="cboApartmentNumber" style="width:150px">
			<%
				ApartmentsDAO objDao= new ApartmentsDAO();
				List<Apartments> lstOff = objDao.findAll();
				for( Iterator it = lstOff.iterator(); it.hasNext(); ) {
							Apartments apartment = (Apartments)it.next();
			 %> 				
			<option value="<%=apartment.getId()%>"><%=apartment.getApartmentNumber()%>
			</option>
			<%} %>
			</select>
			<script type="text/javascript">
			//alert(123);
				var cbo = document.getElementById("cboApartmentNumber");
				//alert('<%=sApartID%>');
				for(i=0; i<cbo.options.length; i++)
				{
					//alert(cbo.options[i].value);
					if(cbo.options[i].value == '<%=sApartID%>')
					{
						cbo.options[i].selected = true;
						break;
					}
				}
			</script>
										</td>
										
									</tr>
									<tr>
										<td>
											&nbsp;Equipment Name
										</td>
										<td>
											&nbsp;
											<select id="cboApartmentNumber" name="cboEquipmentName" style="width:150px">
			<%
				EquipmentsDAO objDao1= new EquipmentsDAO();
				List<Equipments> lstOff1 = objDao1.findAll();
				for( Iterator it = lstOff1.iterator(); it.hasNext(); ) {
							Equipments equipment = (Equipments)it.next();
			 %> 				
			<option value="<%=equipment.getId()%>"><%=equipment.getEquipmentName()%>
			</option>
			<%} %>
			</select>
			<script type="text/javascript">
			
				var cbo = document.getElementById("cboEquipmentName");
			
				for(i=0; i<cbo.options.length; i++)
				{
					//alert(cbo.options[i].value);
					if(cbo.options[i].value == '<%=sEquipID%>')
					{
						cbo.options[i].selected = true;
						break;
					}
				}
			</script>
			</td>
										
									</tr>
											<tr>
										<td valign="top">
											<input type="submit" value="Update" name="btnUpdate"
												class="submit" />
										</td>
										<td valign="top">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<input type="button" value="Back" name="btnBack"
												onClick="self.location='Manage_EquipmentDetails.jsp'" />
										</td>
										
									</tr>
								</tbody>
							</table>
						</td>
					</tr>
					<tr>
					</tr>
					</tbody>
					</table>
				</div>
			</form>
      
   
  
  </body>
</html>
